package com.chen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.entity.Account;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

@Mapper
public interface AccountMapper extends BaseMapper<Account> {
    @Update("update t_account set amount = amount +  #{amount} ,frozen_amount = frozen_amount-#{amount} where id =#{accountId} and frozen_amount > 0")
    void unfreezeAmount(@Param("accountId") int accountId, @Param("amount") BigDecimal amount);

    @Update("update t_account set frozen_amount=frozen_amount-#{amount} where id =#{accountId} and frozen_amount > 0")
    void transferOut(@Param("accountId") int accountId, @Param("amount") BigDecimal amount);
}
